//
//  MainRow.m
//  NetMobileLocation
//
//  Created by Mehmet Sinan Şahin on 3/3/12.
//  Copyright (c) 2012 netgis. All rights reserved.
//

#import "MainRow.h"
#import "NGLocation.h"

@implementation MainRow

@synthesize imgStatus;
@synthesize lblDate;
@synthesize lblDateFriendly;
@synthesize lblSpeed;


- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

+(UITableViewCell *)createCell:(UITableView *)tableView cellIdentifier: (NSString *)cellIdentifier location:(NGLocation *)location {
    MainRow *cell = (MainRow *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (cell == nil) {
        NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"MainRow" owner:self options:nil];
        for (id currentObj in topLevelObjects) {
            if ([currentObj isKindOfClass:[UITableViewCell class]]) {
                cell = (MainRow *) currentObj;
            }
        }
    }
    
    [cell.imageView setImage:[NGUtility imageForNGLocationStatus:location]];
    
    [cell.lblDate setText:[location.tarihSaat toFormattedStringAsTime]];
    [cell.lblSpeed setText:[NGUtility friendlySpeed:location]];
    [cell.lblDateFriendly setText:[location.tarihSaat formatRelativeTime]];
    return cell;
}

@end
